﻿var curUrl = top.location.href.toLowerCase();
if (curUrl.indexOf("login.aspx") == -1 && curUrl.indexOf("index.aspx") == -1) {
    top.location.replace("../index/index.aspx");
}

function IsOnLine() {
    var isOnline = true;
    $.ajax({ url: "../login/login.aspx", type: "post", data: { AjaxCheckLogin: 1 }, dataType: "text", async: false, success: function (isLogin) {

        if (!!!(isLogin - 0)) {

            Logout();
            isOnline = false;
        }
    }
    });
    return isOnline;
}

function Logout() {
    $.ajax({ url: "../login/login.aspx", type: "post", data: { AjaxLogout: 1 }, async: false, success: function () { top.location.replace("../login/login.aspx"); } });
}

function GoTop() {
    if (window !== window.top) {
        window.top.location = location;
    }
}

function AdjustIframeHeight(iframeSelector) {    
    var iframe = $(iframeSelector);
    var h1 = iframe.parent().height();
//    var h2 = iframe.contents().find("body")[0].scrollHeight + 5; //alert(h1 + " " + h2);
    iframe[0].style.height = h1 + "px";// Math.min(h1, h2) + "px";
    iframe[0].style["-moz-box-shadow"] = "2px 2px 3px 0 rgba(0, 0, 0, 0.3) inset";
}

function QueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
}

function AjaxError(data) {
    if (data && (data instanceof Object) && ('errorMsg' in data) && ("errorId" in data)) {
        alert(data.errorMsg);
        return true;
    }
    return false;
}

function ShowLeftMenu(leftSelector,a) {
    $("#topMenu a").removeClass("nav_a_link");
    $(a).addClass("nav_a_link");
    $("[flag=leftmenu]").hide();
    $(leftSelector).show();
}

